package com.sbr.seb.rule.composite;

import java.util.Arrays;

import com.sbr.seb.rule.Specification;
import com.sbr.seb.rule.exception.SpecificationException;

public class AndSpecification<T> extends AbstractCompositeSpecification<T> {
	 
    @Override
    public boolean isSatisfiedBy(final T candidate) throws SpecificationException {
        boolean result = true;
 
        for (Specification<T> specification : this.specifications) {
            result &= specification.isSatisfiedBy(candidate);
        }
        return result;
    }
 
    public AndSpecification(Specification<T>... specifications) {
        this.specifications = Arrays.asList(specifications);
    }
    
}